﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Model;
using BLL;

namespace ERPWeb
{
    public partial class RawsManagerWeb : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                ShowRawsAll();
            }
        }

        private void ShowRawsAll()
        {
            //绑定数据
            this.gvRawsInfo.DataSource = RawsInfoManager.GetAll();
            //展示
            this.gvRawsInfo.DataBind();
        }

        protected void btnAdd_Click(object sender, EventArgs e)
        {
            Response.Redirect("RawsAddWeb.aspx");
        }

        protected void btnChange_Click(object sender, EventArgs e)
        {
            Response.Redirect("RawsChangeWeb.aspx");
        }

        protected void gvRawsInfo_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            //分页
            this.gvRawsInfo.PageIndex = e.NewPageIndex;
            ShowRawsAll();
        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            this.gvRawsInfo.DataSource = RawsInfoManager.GetAllMessage(txtRawsName.Text, txtRawsAddress.Text, txtRawsSupplier.Text);
            this.gvRawsInfo.DataBind();
            txtRawsName.Text = "";
            txtRawsAddress.Text = "";
            txtRawsSupplier.Text = "";
        }

        protected void btnReturn_Click(object sender, EventArgs e)
        {
            ShowRawsAll();
            txtRawsName.Text = "";
            txtRawsAddress.Text = "";
            txtRawsSupplier.Text = "";
        }
    }
}